Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Fix public API decorator type annotations. #1397

Merged
merged 1 commit into from
Sep 21, 2023

Conversation

clarkzinzow
Copy link
Contributor

@clarkzinzow clarkzinzow commented Sep 20, 2023

This PR fixes the type annotations for functions/methods that are wrapped with the public API decorator. Namely, we replace Callable[..., Any] for the input and return type of the decorator with Callable[P, T], where T = TypeVar("T") and P = ParamSpec("P"); we then bind T to the return type and P.args and P.kwargs to the args and kwargs, respectively, of the wrapper function. This ensures that the type annotations of the wrapped function/method are properly propagated to the returned wrapper function.

@github-actions github-actions bot added the bug Something isn't working label Sep 20, 2023
@codecov
Copy link

codecov bot commented Sep 20, 2023

Codecov Report

Merging #1397 (4f1241b) into main (f6370e5) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1397      +/-   ##
==========================================
+ Coverage   87.79%   87.80%   +0.01%     
==========================================
  Files          60       60              
  Lines        6031     6036       +5     
==========================================
+ Hits         5295     5300       +5     
  Misses        736      736              
Files Changed Coverage Δ
daft/api_annotations.py 89.06% <100.00%> (+0.92%) ⬆️

@clarkzinzow clarkzinzow merged commit 16c1553 into main Sep 21, 2023
31 checks passed
@clarkzinzow clarkzinzow deleted the clark/fix-decorator-typing branch September 21, 2023 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants